package cn.ad.enumration;

import java.util.LinkedHashMap;
import java.util.Map;

public enum Connection {
	UNKOWN(0, "其它"), 
    WIFI(1,"Wifi"),
    NET2G(2,"2G"),
    NET3G(3,"3G"),
    NET4G(4,"4G");
	
    private static java.util.HashMap<Integer,String> mappings;

    private synchronized static java.util.HashMap<Integer,String> getMappings() {
        if (mappings == null) {
            mappings = new LinkedHashMap<Integer,String>();
            for (Connection format : Connection.values()) {
                mappings.put(format.value, format.name);
            }
        }
        return mappings;
    }

    private String name;
    private int value;

    private Connection(int value,String name) {
        this.name = name;
        this.value = value;
    }

    public String getName() {
        return name;
    }

	public int getValue() {
		return value;
	}
	public static String forValue(int value) {
		return getMappings().get(value);
	}
	
	 public static Map<Integer,String> getMapping(){
	        return getMappings();
	 }
}
